libxl: Record backend/frontend paths in /libxl/$DOMID
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 27 Apr 2016 14:50:01 +0000 (15:50 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 2 Jun 2016 14:53:28 +0000 (15:53 +0100)
commit811b188addb9018d1daef19db73c577e9e99f7eb
tree5dfcb60b6ca8f5ac32021c87a39e0c9b2d032d32
parent181677977fc35ddb848ae4d440fbb72e8afc8a1e
libxl: Record backend/frontend paths in /libxl/$DOMID

This gives us a record of all the backends we have set up for a
domain, which is separate from the frontends in
  /local/domain/$DOMID/device.

In particular:

1. A guest has write permission for the frontend path:
  /local/domain/$DOMID/device/$KIND/$DEVID
which means that the guest can completely delete the frontend.
(They can't recreate it because they don't have write permission
on the containing directory.)

2. A guest has write permission for the backend path recorded in the
frontend, ie, it can write to
  /local/domain/$DOMID/device/$KIND/$DEVID/backend
which means that the guest can break the association between
frontend and backend.

So we can't rely on iterating over the frontends to find all the
backends, or examining a frontend to discover how a device is
configured.

So, have libxl__device_generic_add record the frontend and backend
paths in /libxl/$DOMID/device, and have libxl__device_destroy remove
them again.

Create the containing directory /libxl/GUEST/device in
libxl__domain_make.  The already existing xs_rm in devices_destroy_cb
will take care of removing it.

This is part of XSA-175.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
---
v2: Correct actual path computation (!)
v3: Correct actual path computation - really this time (!)
docs/misc/xenstore-paths.markdown
tools/libxl/libxl_create.c
tools/libxl/libxl_device.c
tools/libxl/libxl_internal.h